from pms.common.views import PostFormula
from project.models import ProjectDocument, Project


class API(PostFormula):
    def handle(self, req):
        pid = req['pid']
        docs = ProjectDocument.objects.filter(
            pid=Project.objects.get(id=pid)
        )
        doc_views = [{
            'id': doc.id,
            'name': doc.name,
            'href': doc.href
        } for doc in docs]
        return self.success_respond({
            'list': doc_views
        })
